from PIL import Image, ImageDraw, ImageFont
import os

def create_default_images():
    # 确保目录存在
    os.makedirs('static/img', exist_ok=True)
    
    try:
        # 尝试加载中文字体
        font = ImageFont.truetype("simhei.ttf", 40)
        large_font = ImageFont.truetype("simhei.ttf", 60)
    except IOError:
        # 如果找不到中文字体，使用默认字体
        font = ImageFont.load_default()
        large_font = ImageFont.load_default()
    
    # 创建英雄背景图片
    hero_bg = Image.new('RGB', (1920, 1080), color=(0, 102, 204))
    d = ImageDraw.Draw(hero_bg)
    d.text((960, 540), "海底世界", fill=(255, 255, 255), font=large_font, anchor="mm")
    hero_bg.save('static/img/hero-bg.jpg')
    
    # 创建课程默认图片
    img = Image.new('RGB', (800, 600), color=(0, 102, 204))
    d = ImageDraw.Draw(img)
    d.text((400, 300), "课程图片", fill=(255, 255, 255), font=font, anchor="mm")
    img.save('static/img/default-course.jpg')
    
    # 创建教练默认图片
    img = Image.new('RGB', (400, 400), color=(0, 102, 204))
    d = ImageDraw.Draw(img)
    d.text((200, 200), "教练照片", fill=(255, 255, 255), font=font, anchor="mm")
    img.save('static/img/default-coach.jpg')
    
    # 创建活动默认图片
    img = Image.new('RGB', (1200, 800), color=(0, 102, 204))
    d = ImageDraw.Draw(img)
    d.text((600, 400), "活动图片", fill=(255, 255, 255), font=font, anchor="mm")
    img.save('static/img/default-activity.jpg')
    
    # 创建CTA背景图片
    cta_bg = Image.new('RGB', (1920, 600), color=(0, 102, 153))
    d = ImageDraw.Draw(cta_bg)
    d.text((960, 300), "立即行动", fill=(255, 255, 255), font=large_font, anchor="mm")
    cta_bg.save('static/img/cta-bg.jpg')
    
    # 创建客户评价图片
    for i in range(1, 4):
        testimonial = Image.new('RGB', (200, 200), color=(0, 102, 204))
        d = ImageDraw.Draw(testimonial)
        d.text((100, 100), f"客户{i}", fill=(255, 255, 255), font=font, anchor="mm")
        testimonial.save(f'static/img/testimonial-{i}.jpg')
    
    # 创建特色图标背景
    for i in range(1, 5):
        feature = Image.new('RGB', (300, 200), color=(0, 102, 204))
        d = ImageDraw.Draw(feature)
        d.text((150, 100), f"特色{i}", fill=(255, 255, 255), font=font, anchor="mm")
        feature.save(f'static/img/feature-{i}.jpg')

    # 创建视差背景图片
    parallax_bg = Image.new('RGB', (1920, 1080), color=(0, 51, 102))
    d = ImageDraw.Draw(parallax_bg)
    d.text((960, 540), "海底探险", fill=(255, 255, 255), font=large_font, anchor="mm")
    parallax_bg.save('static/img/parallax-bg.jpg')

if __name__ == "__main__":
    create_default_images()
    print("所有默认图片已创建完成！") 